//
//  Loan_FaceRecognitionViewController.m
//  JinFuThree
//
//  Created by 爱尚 on 2018/9/13.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "Loan_FaceRecognitionViewController.h"
#import "Loan_OperatorAccreditViewController.h"

@interface Loan_FaceRecognitionViewController ()
@property(nonatomic,strong)UIScrollView *myScrollView;

@end

@implementation Loan_FaceRecognitionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"刷脸认证";
    self.view.backgroundColor = ListMaoBackgroundColor;
    [self initViews];
}

-(void)initViews{
    
    UIView *contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidthMao, 600)];
    contentView.backgroundColor = [UIColor whiteColor];
    
    UIView *whiteView = [[UIView alloc]init];
    whiteView.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:whiteView];
    [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(contentView);
        make.height.mas_offset(@385);
    }];
    
    UIView *progressView = [[UIView alloc]init];
    progressView.backgroundColor = ThemeMaoColor;
    [self.view addSubview:progressView];
    [progressView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(self.view);
        make.width.mas_offset(@(ScreenWidthMao/6*4));
        make.height.mas_offset(@2);
    }];
    
    UILabel *topLabel = [[UILabel alloc]init];
    topLabel.text = @"请正对手机屏幕，并确保光线充足";
    topLabel.textAlignment = NSTextAlignmentCenter;
    topLabel.font = [UIFont systemFontOfSize:16];
    topLabel.textColor = ThemeMaoBlackColor;
    [contentView addSubview:topLabel];
    [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(contentView);
        make.top.mas_equalTo(contentView.mas_top).offset(ScreenWidthMao/375*38);
        make.height.mas_offset(@16);
    }];
    
    UIImageView *centerImageView = [[UIImageView alloc]init];
    centerImageView.image = [UIImage imageNamed:@"loan_ic_shualian"];
    [contentView addSubview:centerImageView];
    [centerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(topLabel.mas_bottom).offset(ScreenWidthMao/375*41);
        make.width.mas_offset(@(ScreenWidthMao/375*177));
        make.height.mas_offset(@(ScreenWidthMao/375*217));
        make.centerX.mas_equalTo(contentView);
    }];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn1 setTitle:@"不能佩戴眼镜" forState:UIControlStateNormal];
    [btn1 setTitleColor:ThemeTintFontColor forState:UIControlStateNormal];
    [btn1 setImage:[UIImage imageNamed:@"loan_ic_noyj"] forState:UIControlStateNormal];
    [btn1 setImage:[UIImage imageNamed:@"loan_ic_noyj"] forState:UIControlStateSelected];
    btn1.titleLabel.font = [UIFont systemFontOfSize:13];
    btn1.userInteractionEnabled = NO;
    [contentView addSubview:btn1];
    [btn1 layoutButtonWithEdgeInsetsStyle:XNButtonEdgeInsetsStyleTop imageTitleSpace:10];
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(contentView);
        make.top.mas_equalTo(centerImageView.mas_bottom).offset(ScreenWidthMao/375*50);
        make.width.mas_offset(@(ScreenWidthMao/3));
        make.height.mas_offset(@90);
    }];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn2 setTitle:@"不能遮挡脸部" forState:UIControlStateNormal];
    [btn2 setTitleColor:ThemeTintFontColor forState:UIControlStateNormal];
    [btn2 setImage:[UIImage imageNamed:@"loan_ic_nozd"] forState:UIControlStateNormal];
    [btn2 setImage:[UIImage imageNamed:@"loan_ic_nozd"] forState:UIControlStateSelected];
    btn2.titleLabel.font = [UIFont systemFontOfSize:13];
    btn2.userInteractionEnabled = NO;
    [contentView addSubview:btn2];
    [btn2 layoutButtonWithEdgeInsetsStyle:XNButtonEdgeInsetsStyleTop imageTitleSpace:10];
    [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(btn1.mas_right);
        make.centerY.height.width.mas_equalTo(btn1);
    }];
    
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn3 setTitle:@"不能仰头俯拍" forState:UIControlStateNormal];
    [btn3 setTitleColor:ThemeTintFontColor forState:UIControlStateNormal];
    [btn3 setImage:[UIImage imageNamed:@"loan_ic_noyt"] forState:UIControlStateNormal];
    [btn3 setImage:[UIImage imageNamed:@"loan_ic_noyt"] forState:UIControlStateSelected];
    btn3.userInteractionEnabled = NO;
    btn3.titleLabel.font = [UIFont systemFontOfSize:13];
    [contentView addSubview:btn3];
    [btn3 layoutButtonWithEdgeInsetsStyle:XNButtonEdgeInsetsStyleTop imageTitleSpace:10];
    [btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(btn2.mas_right);
        make.centerY.height.width.mas_equalTo(btn1);
    }];
    
    
    _tipLabel = [[UILabel alloc]init];
    _tipLabel.text = @"请确保*深本人操作";
    _tipLabel.textColor = ThemeMaoBlackColor;
    _tipLabel.textAlignment = NSTextAlignmentCenter;
    _tipLabel.font = [UIFont systemFontOfSize:16];
    [contentView addSubview:self.tipLabel];
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(btn1.mas_bottom).offset(ScreenWidthMao/375*60);
        make.left.right.mas_equalTo(contentView);
        make.height.mas_offset(@16);
    }];
    
    
    
    self.myScrollView = [[UIScrollView alloc]initWithFrame:CGRectZero];
    self.myScrollView.contentSize = contentView.frame.size;
    self.myScrollView.showsVerticalScrollIndicator = NO;
    self.myScrollView.backgroundColor = [UIColor whiteColor];
    [self.myScrollView addSubview:contentView];
    [self.view addSubview:self.myScrollView];
    [self.myScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(2);
        make.bottom.mas_equalTo(self.view).offset(SafeAreaBottomHeight);
    }];
    
    
    UIButton *startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [startBtn setTitle:@"开始拍摄" forState:UIControlStateNormal];
    [startBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [startBtn setBackgroundImage:[UIImage imageNamed:@"select_btn"] forState:UIControlStateNormal];
    [startBtn setBackgroundColor:ThemeMaoColor];
    startBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [startBtn addTarget:self action:@selector(startBtnAction) forControlEvents:UIControlEventTouchUpInside];
    startBtn.frame = CGRectMake(0, ScreenHeight-50-64, ScreenWidthMao, 50);
    [self.view addSubview:startBtn];

    
   
    
    CAGradientLayer *caLayer = [CAGradientLayer layer];
    caLayer.frame = startBtn.bounds;
    caLayer.startPoint = CGPointMake(0, 0);
    caLayer.endPoint = CGPointMake(1, 0);
    //设置颜色数组
    caLayer.colors = @[(__bridge id)HexColor(0xE4D1AD).CGColor,
                       (__bridge id)HexColor(0xBEA471).CGColor];
    
    //设置颜色分割点（范围：0-1）
    caLayer.locations = @[@(0.0f), @(1.0f)];
    [startBtn.layer addSublayer:caLayer];
    
    UILabel *label1 = [[UILabel alloc]init];
    label1.text = @"开始拍摄";
    label1.textColor = [UIColor whiteColor];
    label1.font = [UIFont systemFontOfSize:15];
    label1.textAlignment = NSTextAlignmentCenter;
    label1.frame = startBtn.frame;
    label1.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(startBtnAction)];
    [label1 addGestureRecognizer:tap];
    [self.view addSubview:label1];
    
}

-(void)startBtnAction{
    
    Loan_OperatorAccreditViewController *operatorVC = [[Loan_OperatorAccreditViewController alloc]init];
    [self.navigationController pushViewController:operatorVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
